/*
** HFCL - HybridOS Foundation Class Library
**
** Copyright (C) 2018 Beijing FMSoft Technologies Co., Ltd.
**
** This file is part of HFCL.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program.  If not, see <https://www.gnu.org/licenses/>.
*/

// NOTE
// This file is auto-generated by using 'css_code_generator.py'.
// Please take care when you modify this file mannually.

#ifndef HFCL_CSS_CSSDECLARED_H_
#define HFCL_CSS_CSSDECLARED_H_

#include "../common/common.h"
#include "../common/stlalternative.h"
#include "../css/csspropertyvalue.h"
#include "../css/css.h"

namespace hfcl {

/* VincentWei:
 * for map, the size of key type must be aligned at intptr_t.
 * Or it->second cannot work correctly, you will get SEGV.
 */
MAP(intptr_t, CssPropertyValue*, CssPropertyValueMap);

class CssDeclared : public Css {
public:
    CssDeclared(const char* selector = "") : m_selector (selector) {}
    ~CssDeclared();

#include "cssdeclared.inc"

    // The helper functions for setting margin-* properties in batches.
    bool setMargin(Uint32 value);
    bool setMargin(Uint32 value, const HTReal* r);

    // The helper functions for setting padding-* properties in batches.
    bool setPadding(Uint32 value);
    bool setPadding(Uint32 value, const HTReal* r);

    // The helper function for setting text-align property.
    // In CSS3 or later, text-align is defined as a shorthand of
    // text-align-all and text-align-last
    bool setTextAlign(Uint32 value);

    // The helper function for setting word-wrap property.
    // In CSS3 or later, for legacy reasons, UAs must treat
    // word-wrap as an legacy name alias of the overflow-wrap property.
    bool setWordWrap(Uint32 value) {
        return setOverflowWrap(value);
    }

    virtual bool getProperty(CssPropertyIds pid, Uint32 *value,
            HTPVData* data) const;
    virtual bool setProperty(CssPropertyIds pid, Uint32 value,
            HTPVData data);

    const char* getSelector() const { return m_selector; }
    const CssPropertyValueMap& getMap() const { return m_map; }

    friend class View;

private:
    const char* m_selector;
    CssPropertyValueMap m_map;
};

} // namespace hfcl

#endif /* HFCL_CSS_CSSDECLARED_H_ */
